package cn.edu.imnu.vacate.users.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.edu.imnu.vacate.leave.pojo.ALeave;
import cn.edu.imnu.vacate.users.enums.AUserEnum;

/**
 * 用户表的POJO
 * @author MCR
 *
 */
public class AUser
{
	private int id;
	private int rid;
	private int tid;
	private String cname;
	private String loginName;
	private String name;
	private String password;
	private String teacher;
	private byte status;
	private Date createTime;
	private Date updateTime;
	private Date lastLoginTime;
	/*状态*/
	private String statusStr;
	/*关联关系*/
	private ARole role;
	private List<ALeave> leaveList = new ArrayList<ALeave>();
	
	
	public String getStatusStr()
	{
		/**
		 * 状态：0 禁用；1启用；
		 */
		AUserEnum[] userEnums = AUserEnum.values();
		for (int i = 0; i < userEnums.length; i++)
		{
			AUserEnum userEnum = userEnums[i];
			if(userEnum.toString().startsWith("STATUS"))
			{
				if(userEnum.getStatus() == this.status)
				{
					this.statusStr = userEnum.getInfo();
					/*
					 * 提高效率；
					 * 数据库中存储的值肯定是枚举中 的一个值
					 */
					break;
				}
			}
		}
		return statusStr;
	}
	public ARole getRole()
	{
		return role;
	}
	public void setRole(ARole role)
	{
		this.role = role;
	}
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	
	public String getPassword()
	{
		return password;
	}
	public void setPassword(String password)
	{
		this.password = password;
	}
	public byte getStatus()
	{
		return status;
	}
	public void setStatus(byte status)
	{
		this.status = status;
	}
	public Date getCreateTime()
	{
		return createTime;
	}
	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}
	public Date getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}
	public Date getLastLoginTime()
	{
		return lastLoginTime;
	}
	public void setLastLoginTime(Date lastLoginTime)
	{
		this.lastLoginTime = lastLoginTime;
	}
	public int getRid()
	{
		return rid;
	}
	public void setRid(int rid)
	{
		this.rid = rid;
	}
	public String getLoginName()
	{
		return loginName;
	}
	public void setLoginName(String loginName)
	{
		this.loginName = loginName;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public List<ALeave> getLeaveList()
	{
		return leaveList;
	}
	public void setLeaveList(List<ALeave> leaveList)
	{
		this.leaveList = leaveList;
	}
	public int getTid()
	{
		return tid;
	}
	public void setTid(int tid)
	{
		this.tid = tid;
	}
	public String getCname()
	{
		return cname;
	}
	public void setCname(String cname)
	{
		this.cname = cname;
	}
	public String getTeacher()
	{
		return teacher;
	}
	public void setTeacher(String teacher)
	{
		this.teacher = teacher;
	}
	
}
